<?php

declare(strict_types=1);

namespace App\Controller\Api;

use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Psr\Container\ContainerInterface;

abstract class AbstractController
{
    #[Inject]
    protected ContainerInterface $container;

    #[Inject]
    protected RequestInterface $request;

    #[Inject]
    protected ResponseInterface $response;

    protected function returnError(string $message = '', int $code = 600): array
    {
        return [
            'code' => $code,
            'data' => ['date' => date('Y-m-d H:i:s')],
            'message' => $message,
        ];
    }

    protected function returnSuccess($data = null, string $message = ''): array
    {
        return [
            'code' => 200,
            'data' => $data,
            'message' => $message,
        ];
    }
}
